//
//  ViewController.m
//  按钮移动图片
//
//  Created by student on 16/2/29.
//  Copyright © 2016年 niit. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *image;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    
}

- (IBAction)up:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (y<0) {
        self.image.frame = CGRectMake(x, y+20, 1600, 1000);
    }
}

- (IBAction)down:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (y>568-1000) {
        self.image.frame = CGRectMake(x, y-20, 1600, 1000);
    }
}

- (IBAction)left:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (x<0) {
        self.image.frame = CGRectMake(x+20, y, 1600, 1000);
    }
}

- (IBAction)right:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (x>320-1600) {
        self.image.frame = CGRectMake(x-20, y, 1600, 1000);
    }
}

- (IBAction)upLeft:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (x<0 && y<0) {
        self.image.frame = CGRectMake(x+20, y+20, 1600, 1000);
    }
}

- (IBAction)upRight:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (x>320-1600 && y<0) {
        self.image.frame = CGRectMake(x-20, y+20, 1600, 1000);
    }
}

- (IBAction)downLeft:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (x<0 && y>568-1000) {
        self.image.frame = CGRectMake(x+20, y-20, 1600, 1000);
    }
}

- (IBAction)downRight:(UIButton *)sender {
    
    int x = self.image.frame.origin.x;
    int y = self.image.frame.origin.y;
    if (x>320-1600 && y>568-1000) {
        self.image.frame = CGRectMake(x-20, y-20, 1600, 1000);
    }
}




@end
